home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
tex
/
hdiff122.zip
/
HDIFF.DOC
< prev
next >
Wrap
Text File
|
1988-01-07
|
25KB
|
594 lines
hdiff 1.22
Purpose
-------
Hdiff compares two DOS text files and records the differences
between them in a third file. Although hdiff can be used for
simple "what's changed?" purposes, its real function is to
assist in maintaining program source code or similar text files
that change over time. By maintaining a original, base file and
a series of "difference" files, it's possible to retain all
versions of a file at a great savings in space over retaining
the full text of all versions.
The hdiff system includes an auxiliary program, hed, that is
used to apply the difference files to the original (although
EDLIN can also be used if the files are small enough).
New in version 1.22
-------------------
The following features have been changed or added since version
1.14, the last publicly released version:
1. A new difference-applier (HED.EXE) is included. This
replaces most use of EDLIN for the hdiff system and allows you
to apply multiple update files in one operation.
2. The syntax of hdiff has changed slightly:
a. A third filename can be supplied on the command line.
This replaces the redirection used in earlier versions.
b. It is no longer necessary to specify a maximum number
of lines (the old -nnnn parameter). For downward
compatibility, hdiff 1.22 will accept and ignore the
parameter if present.
3. The true file date of the original file is retained if you
use hdiff and hed as described below.
4. Maximum line length has been extended to 1000 characters.
Running hdiff
-------------
The general syntax for hdiff is:
hdiff [-ecs] old-file new-file [dif-file]
The simplest use of hdiff is exemplified by:
hdiff oldfile.txt newfile.txt
which displays a simple report of differences between the two
files: it shows which lines of OLDFILE.TXT do not appear in
NEWFILE.TXT (deletions), and which lines of NEWFILE.TXT do not
appear in OLDFILE.TXT (insertions). The simple change report
consists of text lines in this format:
nnnn[+/-] text
A '+' format indicates that the line is new (an insertion); the
'-' indicates that the line is gone (a deletion). Thus:
0001- This line appears in the old file only
0001+ This line appears in the new file only
The 'nnnn' represents the line number. For '+' lines, it's the
line number in the new file; for '-' lines, it's the line number
in the old file.
(Note that the first file named on the command line is always
assumed to be the "old" file, and the second is the "new" file.)
If you want the report to be sent to a text file rather than to
the screen, simply include the file name as a third parameter:
hdiff oldfile.txt newfile.txt changes.txt
NOTE: the simple report does not show lines that have been
moved. The edlin-format report (-e switch) does include moved
lines. Use the -e report for maintaining difference files; the
simple report does not contain enough information.
Optional switches
-----------------
Here are the switches that can optionally be added to the
command line. They must precede the file names:
-c Case insensitive: hdiff ignores differences in
alphabetic case. Thus, the two lines:
This is text
THIS IS TEXT
are not reported as changed.
-e Edlin: produce an edlin-compatible difference file
rather than the simple difference report described
above. This switch is also used to created hed-format
files. See succeeding sections for more information.
-s Space insensitive: hdiff ignores differences in spacing.
This, the two lines:
This is text
This is text
are not reported as changed.
The switches may be combined, and they may be in any order:
-e -c
-ec
-ce
-c -e
are all equivalent. All switches must, however, precede the
first filename.
Examples of hdiff use:
hdiff foo.c newfoo.c
compares file 'foo.c' with file 'newfoo.c' and displays
a simple report showing insertions (lines in newfoo that
do not appear in foo) and deletions (lines in foo that
do not appear in newfoo). Lines that have been moved
but are otherwise unchanged do not appear in this
report.
hdiff -ec foo.c newfoo.c foo.114
compares foo.c with newfoo.c, ignoring case differences,
and prepares an edlin/hed script in the file foo.114.
This script, if applied to foo as described below, will
create a copy of newfoo.
Applying difference files: edlin and version control
----------------------------------------------------------
The main purpose of hdiff is to assist you in maintaining
multiple versions of program source or other text files. Many
programmers like to keep archival copies of old source, for any
of a number of reasons (one reason: sometimes changes don't work
and it's necessary to go back to a previous version!). You
could simply keep an archive or library with the complete text
of all versions, but this is wasteful of disk space.
A better solution (short of purchasing a true SCCS ["Source Code
Control System"] for big bucks) is to use hdiff and hed or edlin
to keep one original source file plus smaller difference files
that can be used to re-create any version.
To see how this works, assume that you have an old version of
your program MYPROG.C (in a file called MYPROG.SCC) and a new
version named MYPROG.C:
myprog.scc (version 1.00)
myprog.c (version 1.10)
To create a difference file, use hdiff:
hdiff -e myprog.scc myprog.c myprog.110
After hdiff is finished, you will have a file (MYPROG.110) that
contains the differences between 1.00 and 1.10. Because of the
-e switch, this file is in a special format: it is actually the
text of a series of edlin commands that would turn version 1.00
source into version 1.10 source. It is an edlin script. So, if
you were to execute the commands (remember that MYPROG.SCC is
version 1.00):
copy myprog.scc myprog.c
edlin myprog.c < myprog.110
the result (after edlin finished) would be a file called
MYPROG.C that contains the source for version 1.10. Thus,
between the original (1.00) MYPROG.SCC and the difference file
MYPROG.110 you have all you need to re-create either version of
the program. Chances are, however, that MYPROG.110 is much
smaller than the full source for MYPROG.C, so considerable
storage is saved.
Note that edlin cannot deal, in this context, with files larger
than about 48K. If you try to apply a difference file to a base
file larger than 48K using edlin, the resultant file will be
damaged and probably unusable. For this reason and others, we
recommend using the supplied program "hed" rather than edlin.
Using hed
---------
Hed is a simple progr